import { defineStore } from 'pinia';
import { getSetting } from '@/api/app';
interface AppState {
	title:string;
	setting:any;
}
const need_keys = [
	'points',		//积分设置
];
export const appStore = defineStore('appStore', {
	state: ():AppState => ({
		title:"",
		setting:{},
	}),
	getters:{
		getApp(state):AppState{
			return {
				title: state.title,
				setting: state.setting,
			}
		}
	},
	actions:{
		async getSetting(){
			try{
				const res:any = await getSetting({
					keys:need_keys
				})
				this.title = res.store.name
				this.setting = res
				return true
			}
			catch(error:any){
				return false
			}
		}
	}
});